﻿using System.Web.Http;
using TY.UC.Log4;

namespace TY.UI.WebApi
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();
            config.Formatters.Remove(config.Formatters.XmlFormatter);
           // config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            config.Filters.Add(new WebApiExceptionAttribute());
            config.Filters.Add(new ApiAuthorityAttribute());
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{action}/{id}",
                defaults: new {ApiController="home",Action="Index", id = RouteParameter.Optional }
            );
            Log4NetConfig.RegisterLog4Net();
            UnityConfig.RegisterComponents();
        }
    }
}
